package dao

import (
	"weekly/initiative"
	"weekly/model"
)

func GetUserByPhoneAndPassword(phone string, password string) (user *model.User) {
	err := initiative.DB.Where("phone =?", phone).Where("password =?", password).Error
	if err == nil {
		return nil
	}
	return user
}

func CreateByPhoneAndPassword(phone string, password string) (user *model.User) {
	user = &model.User{
		Phone:    phone,
		Password: password,
	}
	err := initiative.DB.Where("phone =?", phone).Where("password =?", password).Create(&user).Error
	if err != nil {
		return nil
	}
	return user
}
